package com.my.hotel.mapper;

import com.my.hotel.entity.serverPage.JdUser;
import com.my.hotel.util.ILog;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface JdUserMapper {
    @Select("select * from jd_user")
    List<JdUser> getList();

//    @ILog("添加用户")
    @Insert("insert into jd_user values(null,#{username},#{password},#{name},#{sex},#{via}" +
            ",#{email},#{phone},#{status},#{create_time})")
    @Options(keyProperty = "id",useGeneratedKeys = true)
    void  register(JdUser user);
    @ILog("删除用户")
    @Delete("delete from jd_user where id=#{delId}")
    void delClient(int delId);
    @Select("select * from jd_user where id=#{id}")
    JdUser getClientById(int id);
    @Update("update jd_user set username=#{username},name=#{name},sex=#{sex},email=#{email},phone=#{phone}" +
            "where id=#{id}")
    void clientUpdate(JdUser user);

    @Select("select * from jd_user where username=#{username} and password=#{password}")
    public JdUser isLogin( @Param("username") String username,@Param("password") String password);
@Select("select count(*) from jd_user where username=#{username}")
    public int getCountByUsername(String username);
//    @Select("select COUNT(*) from jd_user where username=#{username}")
//    int getCountByName(String username);


    @Select(("select * from jd_user where username=#{username}"))
    public JdUser cklogin(String username);
}
